<template>
  <el-form
    :inline="true"
    ref="formsRef"
    :model="forms"
    :rules="rulesForm"
    label-width="106px"
    class="demo-form-inline"
  >
    <el-row :gutter="20">
      <el-col :span="8">
        <!-- 单据编号 -->
        <el-form-item label="单据编号" prop="productInspectionCode">
          <el-input
            v-model="forms.productInspectionCode"
            readonly
            @click="selectIdChange"
            :disabled="forms.status === 1"
            placeholder="选择单据编号"
          />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <!-- 检验时间 -->
        <el-form-item label="检验时间" prop="productInspectionTime">
          <el-date-picker
            v-model="forms.productInspectionTime"
            type="datetime"
            format="YYYY-MM-DD HH:mm:ss"
            value-format="YYYY-MM-DD HH:mm:ss"
            :disabled="forms.status === 1"
            placeholder="请选择检验时间"
          />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <!-- 主计量单位 -->
        <el-form-item label="主计量单位" prop="unitName">
          <el-input
            v-model.trim="forms.unitName"
            disabled
            placeholder="请输入主计量单位"
          />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <!-- 存货名称 -->
        <el-form-item label="存货名称" prop="inventoryName">
          <el-input
            v-model.trim="forms.inventoryName"
            disabled
            placeholder="请输入存货名称"
          />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <!-- 检验方式 -->
        <el-form-item label="检验方式" prop="inspectionMethod">
          <el-select
            v-model="forms.inspectionMethod"
            placeholder="请选择检验方式"
            style="width: 100%"
            :disabled="!forms.inspectionQuantity || forms.status === 1"
            @change="(value) => handleInspectionMethodSelectChange(value)"
          >
            <el-option
              v-for="item in inspectionMethodOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <!-- 报检数量 -->
        <el-form-item label="报检数量" prop="inspectionQuantity">
          <el-input-number
            v-model.trim="forms.inspectionQuantity"
            :min="1"
            disabled
            placeholder="请输入报检数量"
          />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <!-- 抽检规则 -->
        <el-form-item label="抽检规则" prop="spotCheckRule">
          <el-select
            v-model="forms.spotCheckRule"
            placeholder="请选择抽检规则"
            :disabled="
              !forms.inspectionQuantity ||
              forms.inspectionMethod === 1 ||
              forms.status === 1
            "
            style="width: 100%"
            @change="(value) => handleSpotCheckRuleSelectChange(value)"
          >
            <el-option
              v-for="item in spotCheckRuleOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <!-- 抽检率% -->
        <el-form-item label="抽检率(%)" prop="spotCheckRate">
          <el-space>
            <el-input-number
              v-model="forms.spotCheckRate"
              placeholder="请输入抽检率"
              :min="1"
              :max="100"
              :step="1"
              :precision="0"
              :disabled="
                !forms.inspectionQuantity ||
                forms.inspectionMethod === 1 ||
                forms.spotCheckRule === 2 ||
                forms.status === 1
              "
              @input="(v) => handleInput(v, 'spotCheckRate')"
            >
              <template #suffix>
                <span>%</span>
              </template>
            </el-input-number>
          </el-space>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <!-- 抽检量 -->
        <el-form-item label="抽检量" prop="spotCheckQuantity">
          <el-input-number
            v-model.trim="forms.spotCheckQuantity"
            :min="0"
            :max="forms.inspectionQuantity"
            :precision="2"
            :disabled="!forms.inspectionQuantity || forms.status === 1"
            placeholder="请输入抽检量"
            @input="(v) => handleInput(v, 'spotCheckQuantity')"
          />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <!-- 检验员 -->
        <el-form-item label="检验员" prop="inspectionId">
          <el-select
            v-model="forms.inspectionId"
            clearable
            :disabled="forms.status === 1"
            placeholder="请选择检验员"
            style="width: 100%"
          >
            <el-option
              v-for="emp in employeeOptions"
              :key="emp.id"
              :label="emp.employeesName"
              :value="emp.id"
            />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <!-- 质检方案编码 -->
        <el-form-item
          label="质检方案编码"
          prop="qualityDetectionInspectionPlanCode"
        >
          <el-input
            v-model.trim="forms.qualityDetectionInspectionPlanCode"
            :disabled="forms.status === 1"
            placeholder="请输入质检方案编码"
          />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <!-- 质检方案-->
        <el-form-item label="质检方案" prop="qualityDetectionInspectionPlanId">
          <el-select
            v-model="forms.qualityDetectionInspectionPlanId"
            clearable
            :disabled="forms.status === 1"
            placeholder="请选择质检方案"
            style="width: 100%"
          >
            <el-option
              v-for="item in detectionInspectionPlanOptions"
              :key="item.qualityDetectionInspectionPlanId"
              :label="item.qualityDetectionInspectionPlanName"
              :value="item.qualityDetectionInspectionPlanId"
              @click="handlePlanSelectChange(item.qualityDetectionInspectionPlanId)"
            />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <!-- 样本合格数 -->
        <el-form-item label="样本合格数" prop="qualifiedQuantity">
          <el-input-number
            v-model.trim="forms.qualifiedQuantity"
            :min="0"
            :precision="2"
            :max="forms.spotCheckQuantity"
            :disabled="!forms.spotCheckQuantity || forms.status === 1"
            placeholder="请输入样本合格数"
            @input="(v) => handleInput(v, 'qualifiedQuantity')"
          />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <!-- 样本不合格数 -->
        <el-form-item label="样本不合格数" prop="unQualifiedQuantity">
          <el-input-number
            v-model.trim="forms.unQualifiedQuantity"
            :min="0"
            :precision="2"
            :max="forms.spotCheckQuantity"
            :disabled="!forms.spotCheckQuantity || forms.status === 1"
            @input="(v) => handleInput(v, 'unQualifiedQuantity')"
            placeholder="请输入样本不合格数"
          />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <!-- 合格接收数量 -->
        <el-form-item label="合格接收数量" prop="receiveQualifiedQuantity">
          <el-input
            v-model.trim="forms.receiveQualifiedQuantity"
            type="number"
            readonly
            :disabled="!forms.spotCheckQuantity || forms.status === 1"
            placeholder="请输入合格接收数量"
          />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-form-item label="备注" prop="remark">
          <el-input
            v-model="forms.remark"
            placeholder="请输入备注"
            type="textarea"
            maxlength="200"
            show-word-limit
            :disabled="forms.status === 1"
          />
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
  <el-divider style="margin: 10px 0"></el-divider>
  <el-button
    style="margin-bottom: 10px"
    type="primary"
    :disabled="forms.status === 1"
    @click="addRow"
    ><i class="el-icon-plus"></i>添加一行</el-button
  >
  <!-- 添加 检验项目 检验指标 -->
  <el-form
    ref="formsTableRef"
    :model="qualityDetectionInspectionPlanDetails"
    label-width="140px"
    class="demo-ruleForm"
  >
    <el-table
      border
      :data="qualityDetectionInspectionPlanDetails"
      ref="inspectionTableRef"
      class="table v-table"
      style="width: 100%"
    >
      <!-- 序号列 -->
      <el-table-column type="index" label="序号" width="60" align="center" />
      <el-table-column label="检验项目">
        <template #default="scope">
          <!--表格里面嵌套表单-->
          <!-- 检验项目 -->
          <el-form-item
            :prop="scope.$index + `.qualityDetectionProjectId`"
            class="not-need-form"
            :rules="{
              required: true,
              message: '检验项目不能为空',
              trigger: ['change', 'blur'],
            }"
          >
            <el-select
              v-model="
                qualityDetectionInspectionPlanDetails[scope.$index]
                  .qualityDetectionProjectId
              "
              :disabled="forms.status === 1"
              placeholder="请选择质检指标所属项目"
              filterable
              @change="(value) => handleSelectChange(value, scope.$index)"
            >
              <el-option
                v-for="item in inspectionProjectDataTemp"
                :key="item.qualityDetectionProjectId"
                :label="item.qualityDetectionProjectName"
                :value="item.qualityDetectionProjectId"
              />
            </el-select>
          </el-form-item>
        </template>
      </el-table-column>
      <!-- 检验指标 -->
      <el-table-column label="检验指标">
        <template #default="scope">
          <el-form-item
            :prop="scope.$index + `.qualityDetectionIndicatorId`"
            class="not-need-form"
            :rules="{
              required: true,
              message: '检验指标不能为空',
              trigger: ['change', 'blur'],
            }"
          >
            <el-select
              v-model="
                qualityDetectionInspectionPlanDetails[scope.$index]
                  .qualityDetectionIndicatorId
              "
              placeholder="请选择检验指标"
              :disabled="
                !qualityDetectionInspectionPlanDetails[scope.$index]
                  .qualityDetectionProjectId || forms.status === 1
              "
              filterable
            >
              <el-option
                v-for="item in inspectionIndicatorsDataTemp.filter(
                  (item) =>
                    item.qualityDetectionProjectId ===
                    qualityDetectionInspectionPlanDetails[scope.$index]
                      .qualityDetectionProjectId
                )"
                :key="item.qualityDetectionIndicatorId"
                :label="item.qualityDetectionIndicatorName"
                :value="item.qualityDetectionIndicatorId"
              />
            </el-select>
          </el-form-item>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="60">
        <template #default="scope">
          <el-button
            @click="
              handleDeleteRow(
                qualityDetectionInspectionPlanDetails[scope.$index]
              )
            "
            type="text"
            style="color: #f54346"
            :disabled="forms.status === 1"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </el-form>

  <!-- 审核弹框选择单据编号 -->
  <dialog-com
    ref="selectDocumentIdRef"
    :title="'单据编号'"
    width="80%"
    @confirm-change="confirmSelectDocumentChange"
    @close-change="closeSelectDocumentChange"
  >
    <template #content>
      <div style="margin-bottom: 10px">
        <el-input
          v-model="documentId"
          clearable
          style="width: 200px"
          placeholder="单据编号"
        />
        <el-button
          type="primary"
          style="margin-left: 10px"
          @click="queryDocumentIdChange"
        >
          <i class="el-icon-search"></i>查询
        </el-button>
      </div>
      <data-table
        ref="documentIdTableRef"
        :tableKey="documentIdTableKey"
        @table-selection-change="documentIdSelectionChange"
      >
      </data-table>
      <!-- 分页 -->
      <div class="table-pagination">
        <el-pagination
          :current-page.sync="currentPage"
          :page-size.sync="pageSize"
          :page-sizes="[15, 30, 50, 80, 100]"
          layout="total, sizes, prev, pager, next, jumper"
          :total="totalPage"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </template>
  </dialog-com>
</template>

<script>
import {
  getProductPlanList,
  getProductInspectionInfo,
} from "@/api/productionManagement/productInspectionForm.js";
export default {
  components: {},
  props: {},
  data() {
    return {
      forms: {},
      rulesForm: {
        productInspectionCode: [
          { required: true, message: "请选择单据编号", trigger: "blur" },
        ],
        productInspectionTime: [
          {
            type: "date",
            required: true,
            message: "请选择检验时间",
            trigger: "change",
          },
        ],
        inspectionMethod: [
          { required: true, message: "请选择检验方式", trigger: "change" },
        ],
        spotCheckRule: [
          { required: true, message: "请选择抽检规则", trigger: "change" },
        ],
        // inspectionQuantity: [
        //   { required: true, message: "请输入报检数量", trigger: "blur" },
        // ],
        spotCheckQuantity: [
          { required: true, message: "请输入抽检量", trigger: "blur" },
        ],
        inspectionId: [
          { required: true, message: "请选择检验员", trigger: "change" },
        ],
        qualityDetectionInspectionPlanCode: [
          { required: true, message: "请输入质检方案编码", trigger: "blur" },
        ],
        qualityDetectionInspectionPlanId: [
          { required: true, message: "请选择质检方案", trigger: "change" },
        ],
      },
      inspectionMethodOptions: [
        { value: 1, label: "全检" },
        { value: 2, label: "破坏性抽检" },
        { value: 3, label: "非破坏性抽检" },
      ],
      spotCheckRuleOptions: [
        { value: 1, label: "比例" },
        { value: 2, label: "定量" },
      ],
      employeeOptions: [],
      inspectionProjectDataTemp: [],
      inspectionIndicatorsDataTemp: [],
      detectionInspectionPlanOptions: [],
      qualityDetectionInspectionPlanDetails: [],
      documentId: "",
      currentPage: 1,
      pageSize: 15,
      totalPage: 0,
      documentIdTableKey: [
        {
          value: "productPlanCode",
          name: "单据编号",
          minWidth: "250",
          sortable: false,
        },
        { value: "remark", name: "备注", minWidth: "250" },
        { value: "creator", name: "创建人", minWidth: "250" },
        { value: "createDate", name: "创建时间", minWidth: "250" },
      ],
      selectDocumentId: [],
    };
  },
  created() {},
  mounted() {},
  methods: {
    // 重置数据
    resetForm() {
      this.forms = {};
      this.inspectionProjectDataTemp = [];
      this.inspectionIndicatorsDataTemp = [];
      this.employeeOptions = [];
      this.detectionInspectionPlanOptions = [];
      // 清空数据
      this.qualityDetectionInspectionPlanDetails = [];
      this.$nextTick(() => {
        this.$refs.formsRef && this.$refs.formsRef.clearValidate();
        this.$refs.formsTableRef && this.$refs.formsTableRef.clearValidate();
      });
    },
    handleSelectChange(value, index) {
      // 重新选择需要清空检验指标
      this.qualityDetectionInspectionPlanDetails[
        index
      ].qualityDetectionIndicatorId = null;
    },
    // 选择单据编号弹出选择框，并获取单据编号列表数据
    selectIdChange() {
      this.$refs.selectDocumentIdRef.dialogVisible = true;
      // 获取单据编号列表数据
      this.queryDocumentIdChange();
    },
    // 获取单据编号列表即生产计划列表
    async queryDocumentIdChange() {
      try {
        const params = {
          ProductPlanCode: this.documentId,
          page: this.currentPage,
          rows: this.pageSize,
        };
        const result = await getProductPlanList(params);
        if (result.status === 0) {
          this.$refs.documentIdTableRef.tableData = result.rows || [];
          this.totalPage = result.total || 0;
        } else {
          this.$message.error("获取数据失败");
        }
      } catch (err) {
        console.error("数据异常:", err);
      }
    },
    // 切换条数
    handleSizeChange(val) {
      this.pageSize = val;
      this.currentPage = 1;
      this.queryDocumentIdChange();
    },
    // 切换页码
    handleCurrentChange(val) {
      this.currentPage = val;
      this.queryDocumentIdChange();
    },
    // 选中的数据
    documentIdSelectionChange(val) {
      this.selectDocumentId = val ? JSON.parse(JSON.stringify(val)) : [];
    },
    // 取消 选择单据编号
    closeSelectDocumentChange() {
      this.documentId = "";
      this.selectDocumentId = [];
      this.$refs.documentIdTableRef.tableData = [];
      this.currentPage = 1;
      this.pageSize = 15;
    },
    // 确认 选择单据编号
    async confirmSelectDocumentChange() {
      if (this.selectDocumentId.length === 0) {
        return this.$message.error("请至少选择一行数据");
      }
      if (this.selectDocumentId.length != 1) {
        return this.$message.error("只能选择一行数据");
      }
      // const oldProductInspectionCode = this.forms.productInspectionCode;
      // 数据回显
      try {
        this.$refs.selectDocumentIdRef.loading = true
        const result = await getProductInspectionInfo(this.selectDocumentId[0].productPlan_Id);
        if (result.ok) {
          // 清空之前的数据
          // if(oldProductInspectionCode && this.forms.productInspectionCode !== oldProductInspectionCode) {
          //   Object.keys(this.forms).forEach(key => {
          //     if (!["productInspectionTime", "productInspectionId", "productInspectionCode", "inspectionId"].includes(key)) {
          //       delete this.forms[key];
          //     }
          //   });
          // }
          console.log("单据详情：", result.data);
          this.forms.productPlanCode = result.data.productPlanCode;
          this.forms.productInspectionCode = result.data.productInspectionCode;
          if (
            result.data &&
            result.data.inspectionInventorys &&
            result.data.inspectionInventorys.length > 0
          ) {
            const planObj = result.data.inspectionInventorys[0];
            this.forms = Object.assign(this.forms, planObj);
            if (
              planObj.qualityDetectionInspectionPlanDetails &&
              planObj.qualityDetectionInspectionPlanDetails.length > 0
            ) {
              this.qualityDetectionInspectionPlanDetails =
                planObj.qualityDetectionInspectionPlanDetails.map(
                  (item, index) => {
                    return {
                      key: index,
                      qualityDetectionIndicatorId:
                        item.qualityDetectionIndicatorId,
                      qualityDetectionProjectId: item.qualityDetectionProjectId,
                    };
                  }
                );
            } else {
              this.qualityDetectionInspectionPlanDetails = [];
            }
            // 如果检验方式选择了全检 抽检量需要赋值
            if (this.forms.inspectionMethod === 1) {
              this.forms.spotCheckQuantity = this.forms.inspectionQuantity;
            }
          }
        } else {
          this.$message.error("获取数据失败");
        }
        this.$refs.selectDocumentIdRef.loading = false;
      } catch (err) {
        this.$refs.selectDocumentIdRef.loading = false;
        console.error("数据异常:", err);
      }
      this.closeSelectDocumentChange();
      this.$refs.selectDocumentIdRef.dialogVisible = false;
    },
    // 选择检验方式
    handleInspectionMethodSelectChange(val) {
      // 全检
      if (val === 1) {
        this.forms.spotCheckRule = 1;
        this.forms.spotCheckRate = 100;
        console.log(this.forms.inspectionQuantity);
        this.forms.spotCheckQuantity = this.forms.inspectionQuantity;
      } else {
        this.forms.spotCheckRule = null;
        this.forms.spotCheckRate = null;
        this.forms.spotCheckQuantity = null;
      }
    },
    // 选择抽检规则
    handleSpotCheckRuleSelectChange(val) {
      // 定量不需要抽检率
      if (val === 2) {
        this.forms.spotCheckRate = null;
      }
    },
    // 选择质检方案
    handlePlanSelectChange(val) {
      if (!val) {
        this.forms.qualityDetectionInspectionPlanCode = "";
        this.qualityDetectionInspectionPlanDetails = [];
      }
      const nowPlanArr = this.detectionInspectionPlanOptions.filter(
        (item) => item.qualityDetectionInspectionPlanId === val
      );
      if (nowPlanArr && nowPlanArr.length > 0) {
        this.forms.qualityDetectionInspectionPlanCode =
          nowPlanArr[0].qualityDetectionInspectionPlanCode;
      }
      this.qualityDetectionInspectionPlanDetails =
        nowPlanArr[0].qualityDetectionInspectionPlanDetails.map(
          (item, index) => {
            return {
              key: index,
              qualityDetectionIndicatorId: item.qualityDetectionIndicatorId,
              qualityDetectionProjectId: item.qualityDetectionProjectId,
            };
          }
        );
    },
    // 增加行数据
    addRow() {
      let index = this.qualityDetectionInspectionPlanDetails.length;
      this.qualityDetectionInspectionPlanDetails.push({
        key: index,
        qualityDetectionProjectId: "",
        qualityDetectionIndicatorId: "",
      });
      console.log(this.qualityDetectionInspectionPlanDetails);
    },
    // 删除行数据
    handleDeleteRow(row) {
      let data = this.qualityDetectionInspectionPlanDetails;
      for (var i = 0; i < data.length; i++) {
        if (data[i].key == row.key) {
          data.splice(i, 1);
        }
      }
    },
    handleInput(val, type) {
      console.log("input值:", val);
      if (val === null && val != 0) return;
      // 报检数量有值情况下 需要进行换算
      if (this.forms.inspectionQuantity) {
        // 抽检率
        if (type === "spotCheckRate") {
          // 抽检量 = 抽检率 / 100 * 报检数量
          this.forms.spotCheckQuantity =
            (val / 100) * this.forms.inspectionQuantity;
          // 默认合格数=抽检量 不合格为0 合格接收数量=报检数量
          this.forms.qualifiedQuantity = this.forms.spotCheckQuantity;
          this.forms.unQualifiedQuantity = 0;
          this.forms.receiveQualifiedQuantity = this.forms.inspectionQuantity;
          return;
        }
        // 抽检量
        if (type === "spotCheckQuantity") {
          // 定量不需要抽检率
          if (this.forms.spotCheckRule !== 2) {
            // 抽检率 = 抽检量 / 报检数量 * 100
            this.forms.spotCheckRate =
              (this.forms[type] / this.forms.inspectionQuantity) * 100;
          }
          // 默认合格数=抽检量 不合格为0 合格接收数量=报检数量
          this.forms.qualifiedQuantity = this.forms[type];
          this.forms.unQualifiedQuantity = 0;
          this.forms.receiveQualifiedQuantity = this.forms.inspectionQuantity;
          return;
        }
        // 样本合格数
        if (type === "qualifiedQuantity") {
          // 样本不合格数
          this.forms.unQualifiedQuantity =
            this.forms.spotCheckQuantity - this.forms[type];
          // 如果抽检规则是比例则 合格接收数量 = 样本合格数 / 抽检率
          // 如果抽检规则是定量则 合格接收数量 = 样本合格数
          this.forms.receiveQualifiedQuantity =
            this.forms.spotCheckRule === 1
              ? (this.forms.qualifiedQuantity / this.forms.spotCheckRate) * 100
              : this.forms.qualifiedQuantity;
          return;
        }
        // 样本不合格数
        if (type === "unQualifiedQuantity") {
          // 样本合格数
          this.forms.qualifiedQuantity =
            this.forms.spotCheckQuantity - this.forms[type];
          // 合格接收数量
          this.forms.receiveQualifiedQuantity =
            this.forms.spotCheckRule === 1
              ? (this.forms.qualifiedQuantity / this.forms.spotCheckRate) * 100
              : this.forms.qualifiedQuantity;
        }
      }
    },
    confirmChange() {
      if (this.forms.status === 1) {
        const approver = `已经审批通过的产品检验单${this.forms.productInspectionCode}不允许修改!`;
        return this.$message.error(approver);
      }
      this.$refs.formsRef.validate((valid) => {
        if (valid) {
          // 抽检量不能大于报检数量
          if (this.forms.spotCheckQuantity > this.forms.inspectionQuantity) {
            return this.$message.error("抽检量不能大于报检数量");
          }
          if (
            !this.forms.qualifiedQuantity &&
            this.forms.qualifiedQuantity !== 0
          ) {
            return this.$message.error("请填写样本合格数");
          }
          if (
            !this.forms.unQualifiedQuantity &&
            this.forms.unQualifiedQuantity !== 0
          ) {
            return this.$message.error("请填写样本不合格数");
          }
          // 样本合格数不能超过抽检数量
          if (this.forms.qualifiedQuantity > this.forms.spotCheckQuantity) {
            return this.$message.error("样本合格数不能超过抽检数量");
          }
          // 样本不合格数不能超过抽检数量
          if (this.forms.unQualifiedQuantity > this.forms.spotCheckQuantity) {
            return this.$message.error("样本不合格数不能超过抽检数量");
          }
          // 样本合格数 + 样本不合格数 = 抽检数量
          // 合格接收数量不能大于报检数量
          if (
            this.forms.receiveQualifiedQuantity > this.forms.inspectionQuantity
          ) {
            return this.$message.error("合格接收数量不能大于报检数量");
          }
          if (this.qualityDetectionInspectionPlanDetails.length === 0) {
            this.$message.error("至少添加一行数据");
            return;
          }
          this.$refs.formsTableRef.validate(async (valid2) => {
            if (valid2) {
              this.$emit("pass-verification-change");
            }
          });
        }
      });
    },
  },
};
</script>

<style lang="less" scoped>
::v-deep {
  .not-need-form {
    .el-form-item__content {
      margin-left: 0 !important;
    }
  }
  .el-date-editor.el-input,
  .el-date-editor.el-input__wrapper,
  .el-input-number {
    width: 100% !important;
  }
  .el-form-item--default .el-form-item__label {
    height: 32px;
    line-height: 20px !important;
    align-items: center !important;
    text-align: right;
  }
  .el-space {
    width: 100% !important;
  }
  .el-space__item {
    margin-right: 0 !important;
    width: 100% !important;
  }
}
.el-form--inline .el-form-item {
  width: 100% !important;
}
.not-need-form.el-form-item--default {
  margin-bottom: 13px !important;
  margin-top: 13px !important;
}
.demo-ruleForm .el-select {
  width: 100%;
}
.table-pagination {
  display: flex;
  justify-content: flex-end;
  padding: 2px 28px;
  border: 1px solid #eee;
  border-top: 0px;
}
</style>
